﻿<ribbon:RibbonWindow x:Class="Atha.Clients.Wpf.MainWindow"
                     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                     xmlns:ribbon="clr-namespace:Microsoft.Windows.Controls.Ribbon;assembly=RibbonControlsLibrary"
                     xmlns:wpf="clr-namespace:Atha.Clients.Wpf"
                     xmlns:vm="clr-namespace:Atha.Clients.ViewModels"
                     Title="Athalon: Acceptance Testing Heuristics Automation" 
                     Height="350" Width="800" Icon="Images\eswat-logo_100x100.png" WindowState="Maximized">
    <ribbon:RibbonWindow.Resources>
        <wpf:BoolToVisibilityConverter x:Key="b2v" FalseValue="Collapsed" />
    </ribbon:RibbonWindow.Resources>
    <ribbon:RibbonWindow.InputBindings>
        <KeyBinding Modifiers="Control" Key="S" Command="{Binding SaveTest.ClickCommand, Mode=OneWay}" />
        <KeyBinding Modifiers="Control" Key="O" Command="{Binding OpenTest.ClickCommand, Mode=OneWay}" />
        <KeyBinding Key="F5" Command="{Binding ExecuteTest.ClickCommand, Mode=OneWay}" />
    </ribbon:RibbonWindow.InputBindings>
    <DockPanel VerticalAlignment="Stretch">
        <ribbon:Ribbon DockPanel.Dock="Top">
            <ribbon:Ribbon.ApplicationMenu>
                <ribbon:RibbonApplicationMenu SmallImageSource="Images\1321920908_text-x-script.png">
                    <ribbon:RibbonApplicationMenuItem DataContext="{Binding OpenTest, Mode=OneTime}" Header="{Binding Text, Mode=OneTime}" ImageSource="{Binding LargeImagePath, Mode=OneTime}" Command="{Binding ClickCommand, Mode=OneTime}" />
                    <ribbon:RibbonApplicationMenuItem DataContext="{Binding SaveTest, Mode=OneWay}" Header="{Binding Text, Mode=OneTime}" ImageSource="{Binding LargeImagePath, Mode=OneTime}" Command="{Binding ClickCommand, Mode=OneWay}" />

                    <ribbon:RibbonApplicationMenu.FooterPaneContent>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <ribbon:RibbonButton x:Name="RibbonAppMenuExit" Grid.Column="1" Label="Exit Athalon" KeyTip="x" SmallImageSource="Images\Close_16x16.png" Click="RibbonAppMenuExit_Click"/>
                        </Grid>
                    </ribbon:RibbonApplicationMenu.FooterPaneContent>
                </ribbon:RibbonApplicationMenu>
            </ribbon:Ribbon.ApplicationMenu>
            <ribbon:RibbonTab Header="Testing">
                <ribbon:RibbonGroup Header="Learn">
                    <ribbon:RibbonToggleButton IsChecked="{Binding IsTutorialVisible, Mode=TwoWay}" Label="{Binding LearnAtha.Text, Mode=OneTime}" LargeImageSource="{Binding LearnAtha.LargeImagePath, Mode=OneTime}" SmallImageSource="{Binding LearnAtha.SmallImagePath, Mode=OneTime}" />
                </ribbon:RibbonGroup>
                <ribbon:RibbonGroup Header="Test Scripts">
                    <ribbon:RibbonButton DataContext="{Binding SaveTest, Mode=OneWay}" Label="{Binding Text, Mode=OneTime}" LargeImageSource="{Binding LargeImagePath, Mode=OneTime}" SmallImageSource="{Binding SmallImagePath, Mode=OneTime}" Command="{Binding ClickCommand, Mode=OneWay}" />
                    <ribbon:RibbonButton DataContext="{Binding ExecuteTest, Mode=OneTime}" Label="{Binding Text, Mode=OneTime}" LargeImageSource="{Binding LargeImagePath, Mode=OneTime}" SmallImageSource="{Binding SmallImagePath, Mode=OneTime}" Command="{Binding ClickCommand, Mode=OneTime}" />
                    <ribbon:RibbonSplitButton Label="{Binding SelectedLanguage.Text, Mode=OneWay}" 
                                              LargeImageSource="{Binding SelectedLanguage.LargeImagePath, Mode=OneWay}" 
                                              SmallImageSource="{Binding SelectedLanguage.SmallImagePath, Mode=OneWay}" 
                                              ItemsSource="{Binding Languages, Mode=OneTime}">
                        <ribbon:RibbonSplitButton.ItemTemplate>
                            <DataTemplate>
                                <ribbon:RibbonMenuItem Header="{Binding Text}" ImageSource="{Binding SmallImagePath}" Command="{Binding ClickCommand, Mode=OneTime}" />
                            </DataTemplate>
                        </ribbon:RibbonSplitButton.ItemTemplate>
                    </ribbon:RibbonSplitButton>
                </ribbon:RibbonGroup>
            </ribbon:RibbonTab>
        </ribbon:Ribbon>
        <Grid DockPanel.Dock="Bottom">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="40*" />
                <ColumnDefinition Width="3" />
                <ColumnDefinition Width="60*" />
            </Grid.ColumnDefinitions>
            <TreeView ItemsSource="{Binding TestResults, Mode=OneWay}" Grid.Column="0" MinWidth="200" Width="Auto" Height="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
                <TreeView.ItemTemplate>
                    <HierarchicalDataTemplate DataType="{x:Type vm:TestResultViewModel}" ItemsSource="{Binding Children, Mode=OneWay}">
                        <StackPanel Orientation="Horizontal">
                            <Image Source="{Binding IconPath, Mode=OneTime}" />
                            <TextBlock Text="{Binding Text, Mode=OneTime}" Margin="5,0,0,0" />
                        </StackPanel>
                    </HierarchicalDataTemplate>
                </TreeView.ItemTemplate>
            </TreeView>
            <GridSplitter Grid.Column="1" Width="3" VerticalAlignment="Stretch" HorizontalAlignment="Center" />
            <TextBox Grid.Column="2" AcceptsReturn="True" AcceptsTab="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Visibility="{Binding IsTestScriptVisible, Mode=OneWay, Converter={StaticResource b2v}}" Text="{Binding TestScript, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
            <FlowDocumentReader Grid.Column="2" Visibility="{Binding IsTutorialVisible, Mode=OneWay, Converter={StaticResource b2v}}">
                <FlowDocument ColumnWidth="400" FontSize="14" FontFamily="Georgia">
                    <Paragraph FontSize="18" FontWeight="Bold">Tutorial: Using Atha</Paragraph>
                    <Paragraph>
                        Welcome to "Atha", the Acceptance Testing Heueristics Automation framework.
                        <LineBreak />
                        <LineBreak />
                        In other words, Atha helps you write Acceptance Tests! The Atha framework and tools
                        are written to give you the most flexibility in authoring, running, and reporting 
                        acceptance tests.
                    </Paragraph>
                </FlowDocument>
            </FlowDocumentReader>
        </Grid>
    </DockPanel>
</ribbon:RibbonWindow>
